package com.all.bll;

import java.sql.SQLException;

import android.accounts.Account;

import com.j256.ormlite.dao.Dao;
import com.j256.ormlite.dao.DaoManager;
import com.j256.ormlite.jdbc.JdbcConnectionSource;
import com.j256.ormlite.support.ConnectionSource;
import com.j256.ormlite.table.TableUtils;

public class Account_bll {
	String databaseURL="jdbc:androidall:mem:Account";
	ConnectionSource connection;
	Dao<Account,String> accountDao;
	public Account_bll()
	{
		try {
			connection = new JdbcConnectionSource(databaseURL);
			accountDao = DaoManager.createDao(connection, Account.class);
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	
	public void cteatedb()
	{
		try {
			TableUtils.clearTable(connection, Account.class);
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	
	public void insert(Account account)
	{
		try {
			accountDao.create(account);
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	
	public void close()
	{
		try {
			connection.close();
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}
